home *** CD-ROM | disk | FTP | other *** search
- // Dynamic link library implementation of SigmoidAxon with adaptible slope
-
- #include "NSDLL.h"
-
- /***********************************/
- /* Forward activation of component */
-
- __declspec(dllexport) void performBiasAxon(
- DLLData *instance, // Pointer to instance data
- NSFloat *data, // Pointer to the layer of processing elements (PEs)
- int rows, // Number of rows of PEs in the layer
- int cols, // Number of columns of PEs in the layer
- NSFloat *bias // Pointer to the layer's bias vector, one for each PE
- )
- {
- int i, length=rows*cols;
- NSFloat *beta = getWeights(instance);
-
- for (i=0; i<length; i++) {
- if (beta[i] < 0.5f)
- beta[i] = 0.5f;
- data[i] = 1.0f / (1.0f + (NSFloat)exp(-(beta[i]*data[i] + bias[i])));
- }
- }
-
- /******************************************/
- /* Management of instance data (OPTIONAL) */
-
- __declspec(dllexport) DLLData *allocBiasAxon(
- DLLData *oldInstance, // Pointer to the last instance if reallocating
- int rows, // Number of rows of PEs in the layer
- int cols // Number of columns of PEs in the layer
- )
- {
- DLLData *instance = allocDLLInstance(oldInstance);
- setWeights(instance, rows*cols);
- return instance;
- }
-
- __declspec(dllexport) void freeBiasAxon(DLLData *instance)
- {
- freeDLLInstance(instance);
- }
-
-